#!/bin/bash

# Check if pip is installed in ubuntu system,
# if installed then print "Pip is installed"

if [ -x "$(command -v pip)" ]; then
    echo "Pip is installed"
    exit 0
fi

http_proxy=http://10.2.12.85:3128/

# backup /etc/apt/sources.list
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# Change the sources.list to use http://mirrors.aliyun.com/ubuntu/ instead of http://nova.clouds.archive.ubuntu.com/ubuntu/
# Change the sources.list to use http://mirrors.aliyun.com/ubuntu/ instead of http://security.ubuntu.com/ubuntu/
sed -i 's/http:\/\/nova.clouds.archive.ubuntu.com\/ubuntu\//http:\/\/mirrors.aliyun.com\/ubuntu\//g' /etc/apt/sources.list
sed -i 's/http:\/\/security.ubuntu.com\/ubuntu\//http:\/\/mirrors.aliyun.com\/ubuntu\//g' /etc/apt/sources.list

# Update the source list
apt -o Acquire::http::Proxy=$http_proxy update

# Install python3-pip use http_proxy
apt -o Acquire::http::Proxy=$http_proxy install -y python3-pip

